From: Brion Vibber Date: Fri, 13 Oct 2006 21:48:19 +0000 (+0000) Subject: * Added global $wgStyleVersion to centralize bumping CSS and JS file versions X-Git-Tag: 1.31.0-rc.0~55504 X-Git-Url: http://git.cyclocoop.org/%22.%24info%5B?a=commitdiff_plain;h=3af8ce82b951dd1b51eef0aa821991ce8a539214;p=lhc%2Fweb%2Fwiklou.git * Added global $wgStyleVersion to centralize bumping CSS and JS file versions for cache-friendly style and script updating --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index d35be10363..dcfb25c1a6 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -44,6 +44,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 6868) Un-hardcode section edit link style * (bug 3205) Stop right floats from stacking horizontally in non-Monobook skins * (bug 2013) Inherit ratios and not computed values for line-height +* Added global $wgStyleVersion to centralize bumping CSS and JS file versions + for cache-friendly style and script updating + == Languages updated == diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 6e35b7106b..b74751acc7 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1024,6 +1024,13 @@ $wgCachePages = true; */ $wgCacheEpoch = '20030516000000'; +/** + * Bump this number when changing the global style sheets and JavaScript. + * It should be appended in the query string of static CSS and JS includes, + * to ensure that client-side caches don't keep obsolete copies of global + * styles. + */ +$wgStyleVersion = '11'; # Server-side caching: diff --git a/includes/EditPage.php b/includes/EditPage.php index a1207d1038..ce224e5269 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -1290,9 +1290,9 @@ END * of the preview button */ function doLivePreviewScript() { - global $wgStylePath, $wgJsMimeType, $wgOut, $wgTitle; + global $wgStylePath, $wgJsMimeType, $wgStyleVersion, $wgOut, $wgTitle; $wgOut->addHTML( '' . "\n" ); $liveAction = $wgTitle->getLocalUrl( 'action=submit&wpPreview=true&live=true' ); return "return !livePreview(" . diff --git a/includes/Feed.php b/includes/Feed.php index 7663e8208f..5c14865d8f 100644 --- a/includes/Feed.php +++ b/includes/Feed.php @@ -149,12 +149,12 @@ class ChannelFeed extends FeedItem { * @private */ function outXmlHeader() { - global $wgServer, $wgStylePath; + global $wgServer, $wgStylePath, $wgStyleVersion; $this->httpHeaders(); echo '' . "\n"; echo '\n"; + htmlspecialchars( "$wgServer$wgStylePath/common/feed.css?$wgStyleVersion" ) . '"?' . ">\n"; } } diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 908dd5cc52..02c4c2e353 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -71,13 +71,13 @@ class ImagePage extends Article { $this->imageHistory(); $this->imageLinks(); if( $exif ) { - global $wgStylePath; + global $wgStylePath, $wgStyleVersion; $expand = htmlspecialchars( wfEscapeJsString( wfMsg( 'metadata-expand' ) ) ); $collapse = htmlspecialchars( wfEscapeJsString( wfMsg( 'metadata-collapse' ) ) ); $wgOut->addHTML( "

" . wfMsgHtml( 'metadata' ) . "

\n" ); $wgOut->addWikiText( $this->makeMetadataTable( $exif ) ); $wgOut->addHTML( - "\n" . + "\n" . "\n" ); } } else { diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 0d55c2e096..f560397ae9 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -481,6 +481,7 @@ class OutputPage { global $wgUser, $wgOutputEncoding, $wgRequest; global $wgContLanguageCode, $wgDebugRedirects, $wgMimeType; global $wgJsMimeType, $wgStylePath, $wgUseAjax, $wgAjaxSearch, $wgScriptPath, $wgServer; + global $wgStyleVersion; if( $this->mDoNothing ){ return; @@ -490,11 +491,11 @@ class OutputPage { $sk = $wgUser->getSkin(); if ( $wgUseAjax ) { - $this->addScript( "\n" ); + $this->addScript( "\n" ); } if ( $wgUseAjax && $wgAjaxSearch ) { - $this->addScript( "\n" ); + $this->addScript( "\n" ); $this->addScript( "\n" ); } @@ -969,7 +970,7 @@ class OutputPage { */ function headElement() { global $wgDocType, $wgDTD, $wgContLanguageCode, $wgOutputEncoding, $wgMimeType; - global $wgUser, $wgContLang, $wgUseTrackbacks, $wgTitle; + global $wgUser, $wgContLang, $wgUseTrackbacks, $wgTitle, $wgStyleVersion; if( $wgMimeType == 'text/xml' || $wgMimeType == 'application/xhtml+xml' || $wgMimeType == 'application/xml' ) { $ret = "\n"; @@ -995,7 +996,7 @@ class OutputPage { } else { $media = "media='print'"; } - $printsheet = htmlspecialchars( "$wgStylePath/common/wikiprintable.css" ); + $printsheet = htmlspecialchars( "$wgStylePath/common/wikiprintable.css?$wgStyleVersion" ); $ret .= "\n"; $sk = $wgUser->getSkin(); diff --git a/includes/ProtectionForm.php b/includes/ProtectionForm.php index fd1bc81e03..f96262fe6b 100644 --- a/includes/ProtectionForm.php +++ b/includes/ProtectionForm.php @@ -212,9 +212,9 @@ class ProtectionForm { } function buildScript() { - global $wgStylePath; + global $wgStylePath, $wgStyleVersion; return ''; } diff --git a/includes/Skin.php b/includes/Skin.php index 3cd3913b2b..6baad7ea95 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -139,7 +139,7 @@ class Skin extends Linker { /** @return string path to the skin stylesheet */ function getStylesheet() { - return 'common/wikistandard.css?2'; + return 'common/wikistandard.css'; } /** @return string skin name */ @@ -296,7 +296,7 @@ class Skin extends Linker { } function getHeadScripts() { - global $wgStylePath, $wgUser, $wgAllowUserJs, $wgJsMimeType; + global $wgStylePath, $wgUser, $wgAllowUserJs, $wgJsMimeType, $wgStyleVersion; global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang; global $wgTitle, $wgCanonicalNamespaceNames, $wgOut; @@ -323,7 +323,7 @@ class Skin extends Linker { $r = self::makeGlobalVariablesScript( $vars ); - $r .= "\n"; + $r .= "\n"; if( $wgAllowUserJs && $wgUser->isLoggedIn() ) { $userpage = $wgUser->getUserPage(); $userjs = htmlspecialchars( self::makeUrl( @@ -360,10 +360,10 @@ class Skin extends Linker { # get the user/site-specific stylesheet, SkinTemplate loads via RawPage.php (settings are cached that way) function getUserStylesheet() { - global $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage; + global $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage, $wgStyleVersion; $sheet = $this->getStylesheet(); $action = $wgRequest->getText('action'); - $s = "@import \"$wgStylePath/$sheet\";\n"; + $s = "@import \"$wgStylePath/$sheet?$wgStyleVersion\";\n"; if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css?1\";\n"; $query = "usemsgcache=yes&action=raw&ctype=text/css&smaxage=$wgSquidMaxage"; diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 9a948215b3..4ae54d96c7 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -932,7 +932,10 @@ class SkinTemplate extends Skin { $siteargs .= '&ts=' . $wgUser->mTouched; } - if ($wgContLang->isRTL()) $sitecss .= '@import "' . $wgStylePath . '/' . $this->stylename . '/rtl.css?1";' . "\n"; + if( $wgContLang->isRTL() ) { + global $wgStyleVersion; + $sitecss .= "@import \"$wgStylePath/$this->stylename/rtl.css?$wgStyleVersion\";\n"; + } # If we use the site's dynamic CSS, throw that in, too if ( $wgUseSiteCss ) { diff --git a/skins/CologneBlue.php b/skins/CologneBlue.php index 8cc8a92552..56127065df 100644 --- a/skins/CologneBlue.php +++ b/skins/CologneBlue.php @@ -18,7 +18,7 @@ if( !defined( 'MEDIAWIKI' ) ) class SkinCologneBlue extends Skin { function getStylesheet() { - return "common/cologneblue.css?4"; + return 'common/cologneblue.css'; } function getSkinName() { return "cologneblue"; diff --git a/skins/MonoBook.php b/skins/MonoBook.php index 92c88c9592..299e5d43f3 100644 --- a/skins/MonoBook.php +++ b/skins/MonoBook.php @@ -56,18 +56,18 @@ class MonoBookTemplate extends QuickTemplate { html('headlinks') ?> <?php $this->text('pagetitle') ?> - - data['printable']) ) { ?>media="print" href="text('stylepath') ?>/common/commonPrint.css?1" /> - - - - - + + + + data ); ?> - + data['jsvarurl' ]) { ?> diff --git a/skins/Nostalgia.php b/skins/Nostalgia.php index 214c70dde2..0d67599d6b 100644 --- a/skins/Nostalgia.php +++ b/skins/Nostalgia.php @@ -18,7 +18,7 @@ if( !defined( 'MEDIAWIKI' ) ) class SkinNostalgia extends Skin { function getStylesheet() { - return 'common/nostalgia.css?2'; + return 'common/nostalgia.css'; } function getSkinName() { return "nostalgia"; diff --git a/skins/Standard.php b/skins/Standard.php index 90bcfc5bc6..517fd19430 100644 --- a/skins/Standard.php +++ b/skins/Standard.php @@ -21,12 +21,12 @@ class SkinStandard extends Skin { * */ function getHeadScripts() { - global $wgStylePath, $wgJsMimeType; + global $wgStylePath, $wgJsMimeType, $wgStyleVersion; $s = parent::getHeadScripts(); if ( 3 == $this->qbSetting() ) { # Floating left $s .= "\n"; + "src='{$wgStylePath}/common/sticky.js?$wgStyleVersion'>\n"; } return $s; } @@ -35,14 +35,14 @@ class SkinStandard extends Skin { * */ function getUserStyles() { - global $wgStylePath; + global $wgStylePath, $wgStyleVersion; $s = ''; if ( 3 == $this->qbSetting() ) { # Floating left $s .= "\n"; + "@import '{$wgStylePath}/common/quickbar.css?$wgStyleVersion';\n\n"; } else if ( 4 == $this->qbSetting() ) { # Floating right $s .= "\n"; + "@import '{$wgStylePath}/common/quickbar-right.css?$wgStyleVersion';\n\n"; } $s .= parent::getUserStyles(); return $s;